import sys
from typing import List


class Solution:
    def numsCount(self, arr: List[int], target: int) -> int:
        result = 0
        nums = []
        for x in arr:
            if x <= target:
                nums.append(x)
        length = 1 << len(nums)
        for i in range(length):
            temp = []
            for j in range(len(nums)):
                if (i >> j) % 2:
                    temp.append(nums[j])

            if sum(temp) == target:
                result += 1
        if result > 0:
            return result
        else:
            return -1


if __name__ == '__main__':
    line_1 = list(map(int, sys.stdin.readline().strip().split(" ")))
    cost = list(map(int, sys.stdin.readline().strip().split(" ")))
    X, M = line_1[0], line_1[1]
    s = Solution()
    print(s.numsCount(cost, X))
